<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of get_relative_index</title>
  <meta name="keywords" content="get_relative_index">
  <meta name="description" content="Returns an index into a mask of the voxels in a pattern xxx">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html . -->
<h1>get_relative_index
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Returns an index into a mask of the voxels in a pattern xxx</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [ia ib vol] = get_relative_index(subj, patname, maskname) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Returns an index into a mask of the voxels in a pattern xxx

 [IDX] = GET_RELATIVE_INDEX(SUBJ, PATNAME, MASKNAME)

 Returns an index of the items in the pattern PATNAME as masked by
 the mask MASKNAME.  This is necessary to apply any mask, stored
 in 3D space, to a pattern, stored as a Voxels x TRs matrix.

 Note: If the mask includes voxels that are not present in the
 pattern, these voxels are excluded from the relative index.

 Optional Form: [IA IB VOL] = GET_RELATIVE_INDEX( ... )
 IA is the relative index of masked voxels in the pattern.  IB is
 the relative index of pattern voxels in the mask.  VOL is a 3D
 volume of the overlap.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>	Returns the MAT field of the object</li><li><a href="get_objfield.html" class="code" title="function [val] = get_objfield(subj,objtype,objname,fieldname)">get_objfield</a>	Retrieves a field from an object</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
</ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [ia ib vol] = get_relative_index(subj, patname, maskname)</a>
0002 
0003 <span class="comment">% Returns an index into a mask of the voxels in a pattern xxx</span>
0004 <span class="comment">%</span>
0005 <span class="comment">% [IDX] = GET_RELATIVE_INDEX(SUBJ, PATNAME, MASKNAME)</span>
0006 <span class="comment">%</span>
0007 <span class="comment">% Returns an index of the items in the pattern PATNAME as masked by</span>
0008 <span class="comment">% the mask MASKNAME.  This is necessary to apply any mask, stored</span>
0009 <span class="comment">% in 3D space, to a pattern, stored as a Voxels x TRs matrix.</span>
0010 <span class="comment">%</span>
0011 <span class="comment">% Note: If the mask includes voxels that are not present in the</span>
0012 <span class="comment">% pattern, these voxels are excluded from the relative index.</span>
0013 <span class="comment">%</span>
0014 <span class="comment">% Optional Form: [IA IB VOL] = GET_RELATIVE_INDEX( ... )</span>
0015 <span class="comment">% IA is the relative index of masked voxels in the pattern.  IB is</span>
0016 <span class="comment">% the relative index of pattern voxels in the mask.  VOL is a 3D</span>
0017 <span class="comment">% volume of the overlap.</span>
0018 
0019 <span class="comment">% This is part of the Princeton MVPA toolbox, released under the</span>
0020 <span class="comment">% GPL. See http://www.csbmb.princeton.edu/mvpa for more</span>
0021 <span class="comment">% information.</span>
0022 
0023 
0024 patmask = <a href="get_objfield.html" class="code" title="function [val] = get_objfield(subj,objtype,objname,fieldname)">get_objfield</a>(subj,<span class="string">'pattern'</span>,patname,<span class="string">'masked_by'</span>);
0025 
0026 patvol = <a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>(subj,<span class="string">'mask'</span>,patmask);
0027 mskvol = <a href="get_mat.html" class="code" title="function [mat] = get_mat(subj,objtype,objname)">get_mat</a>(subj,<span class="string">'mask'</span>,maskname);
0028 
0029 <span class="comment">% Error checking</span>
0030 <span class="keyword">if</span> any(size(patvol) ~= size(mskvol))
0031   error(<span class="string">'Mask and Volume must reference a volume of same dimensions'</span>);
0032 <span class="keyword">end</span>
0033 
0034 iPatvol = find(patvol);
0035 iMskvol = find(mskvol);
0036 
0037 [idx, ia, ib] = intersect(iPatvol, iMskvol);
0038 
0039 vol = zeros(size(patvol));
0040 vol(idx) = 1;</pre></div>
<hr><address>Generated on Thu 08-Sep-2005 12:05:17 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>